package com.emeraldparser.symbol;

import com.emeraldparser.util.Automaton;
import com.emeraldparser.util.Automatons;

/**
 * A symbol class whose automaton contains <em>exactly</em> two vertices:
 * 
 *  <ul>
 *  <li>the state "before" encountering a symbol of this symbol class</li>
 *  <li>the state "after" encountering a symbol of this symbol class</li>
 *  </ul>
 * 
 * @author Adam Paynter
 * 
 */
public abstract class AtomicSymbolClass extends TwoStateSymbolClass {

	/**
	 * Returns an automaton with exactly two states (the "before" and "after"
	 * states). The "before" state is the automaton's only start state. The
	 * "after" state is the automaton's only accept state. One edge is defined
	 * between the "before" and "after" states with this instance as its label.
	 * Child classes are free to modify the automaton.
	 */
	@Override
	public Automaton<? extends State, ? extends SymbolClass> toAutomaton() {
		Automaton<State, SymbolClass> automaton = Automatons.create(super.toAutomaton());
		
		automaton.addDirectedEdge(getBeforeState(), getAfterState(), this);
		
		return automaton;
	}

}
